package com.imc.api.attence.dao.repository;

import com.imc.api.attence.pojo.Sign;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/*
 * 类描述：签到repository
 * 开发者：tanweiping
 * 创建日期：2018/10/28 20:45
 */
@Repository
public interface SignRepository extends JpaRepository <Sign, Integer>, JpaSpecificationExecutor <Sign> {

    /*
     * YT  2018/10/28 20:46
     * 方法描述：根据课时ID查询所有的信息
     */
    List <Sign> findAllByScheduleId(String scheduleId);

    /*
     * YT  2018/10/28 20:46
     * 方法描述：根据主键IDlist删除所有信息
     */
    int deleteAllByIdIn(List <Integer> ids);

    @Modifying
    @Query(nativeQuery = true,value = "update t_sign set status = 0 where id in :ids")
    void deleteByIds(@Param(value = "ids") List<Integer> ids);
}
